package com.aliyun.tools.importdialog;


import org.gnome.gtk.FileChooserAction;
import org.gnome.gtk.FileChooserDialog;
import org.gnome.gtk.ResponseType;
import org.gnome.gtk.Window;

public class ImportFileChooser {
	FileChooserDialog fileChooser;
	
	int selfwidth;
	int selfheight;
	
	private String filePath ="";
	
	/**
	 * 初始化 文件选择控件
	 * @param winMain
	 * @param width
	 * @param height
	 * @param isFolder
	 */
	public ImportFileChooser(Window winMain, int width, int height, boolean isFolder){
		selfwidth = width/2 + 100;
		selfheight = height/2 + 100;
	
		if(isFolder == true){
			this.fileChooser = new FileChooserDialog("打开文件夹",winMain,FileChooserAction.SELECT_FOLDER);
		}else{
			this.fileChooser = new FileChooserDialog("打开文件",winMain,FileChooserAction.OPEN);
		}
		
		fileChooser.setFullscreen(false);
		fileChooser.setDefaultSize(selfwidth, selfheight);			
	}
	
	/**
	 * 启动文件选择控件 
	 * @return
	 */
	public ResponseType Run(){
		return fileChooser.run();
	}
	
	/**
	 * 获得文件路径
	 */
	public String getFilePath(){
		filePath = fileChooser.getFilename();
		return filePath;
	}
	
	/**
	 * 设置文件路径
	 */
	public void setFilePath(String filepath){
		this.filePath = filepath; 
	}
	
	public void hide(){
		fileChooser.hide();
	}
	
	public void showAll(){
		fileChooser.showAll();
	}
	
	
	
}
